<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>平台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="/css/plat-style.css" media="all">
    <style>
        .laydate-time-list>li:nth-child(1) {
            width: 100%;
        }

        .laydate-time-list>li:nth-child(2) {
            display:none !important;
        }

        .laydate-time-list>li:nth-child(3) {
            display:none !important;
        }

        .laydate-time-list ol li {
            width: 100%;
            padding-left: 45%!important;
            font-size: 20px;
            font-weight: bold;
        }
    </style>
</head>
<body>

<div class="layui-container">
    <div class="layui-card">
        <div class="layui-card-body" style="padding-top: 15px;">
            <form class="layui-form" id="seckillAddForm">
                <div class="layui-form-item">
                    <blockquote class="layui-elem-quote block_margin">
                        1. 推荐以活动开始时间命名，如08:00、14:00。<br>
                        2. 开始时间与结束时间必须在同一天内！<br>
                        3. 结束时间不需选择，默认为距离开始时间的一小时！<br>
                        4. 如页面输入信息有误，点击重置按钮即可。
                    </blockquote>
                </div>
                <hr>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="red">*&nbsp;</span>活动名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" class="layui-input" value="${sec.name}" placeholder="推荐以活动开始时间命名，如08:00、14:00">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="red">*&nbsp;</span>开始时间</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" id="startTime" name="startTime" value="${sec.startTime}" readonly onclick="refreshNext()">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="red">*&nbsp;</span>结束时间</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" id="overTime" name="endTime" readonly>
                    </div>
                </div>
            </form>
            <div class="layui-form-item layui-layout-admin">
                <div class="layui-input-block">
                    <div class="layui-footer" style="left: 0;">
                        <button class="layui-btn" onclick="FormSubmit('#seckillAddForm','/activity/seckillAdd')">保存</button>
                        <button class="layui-btn layui-btn-primary" type="button" onclick="resetForm()">重置</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script type="text/javascript" src="/js/jquery/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery.form.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript" src="/js/plugins/image/previewImg.js"></script>
<script>
    layui.config({
        //静态资源所在路径
        base: '/layuiadmin/'
    }).extend({
        //主入口模块
        index: 'lib/index'
    }).use(['index', 'form','laydate'], function(){
        var $ = layui.$,layer = layui.layer,laydate = layui.laydate;
        //日期选择
        var nowTime = new Date();
        var hours = nowTime.getHours(); //获取当前小时数(0-23)
        var minute = nowTime.getMinutes(); //获取当前分钟数(0-59)
        if (minute > 0){
            hours = hours + 1;
        }
        var startTime = laydate.render({
            elem:'#startTime',
            type:'datetime',
            btns: ['confirm'],
            trigger: 'click',
            min:'nowTime',//默认最小值为当前日期
            ready:function(date){
                startTime.config.min={
                    year:date.year,
                    month:date.month-1,//关键
                    date:date.date,
                    hours:hours,
                    minutes:'00',
                    seconds:'00'
                }
            },
            done:function(value,date){
                hours = date.hours + 1;
                var dates = value.split(" ");
                var times = dates[1].split(":");
                var finalTime = dates[0] + " " + times[0] + ":59:59";
                $("#overTime").val(finalTime);
            }/*,
            done:function(value,date){
                hours = date.hours + 1;
                endTime.config.min={
                    year:date.year,
                    month:date.month-1,//关键
                    date:date.date,
                    hours:date.hours
                }
            }*/
        });
        /*var endTime = laydate.render({
            elem:'#endTime',
            type:'datetime',
            trigger: 'click',
            btns: ['confirm'],
            min:'nowTime',//默认最小值为当前日期
            ready:function(date){
                endTime.config.min={
                    year:date.year,
                    month:date.month-1,//关键
                    date:date.date,
                    hours:hours,
                    minutes:'00',
                    seconds:'00'
                }
            },
            done:function(value,date){
                hours = nowTime.getHours();
                if (minute > 0){
                    hours = hours + 1;
                }
            }
        })*/
    });

    /* 选择开始时间清空结束时间 */
    function refreshNext() {
        $("#endTime").val("");
    }

    /* 表单重置 */
    function resetForm(){
        document.getElementById("seckillAddForm").reset();
    }
</script>
</body>
</html>